package com.yvon.boot.common.validation.annotation;

import com.yvon.boot.common.validation.validator.IdCardValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 身份证号码验证
 *
 * @author : Yvon
 * @version : 1.0
 */
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Constraint(validatedBy = IdCardValidator.class)
@Repeatable(IdCard.List.class)
public @interface IdCard {

    /**
     * Message string.
     *
     * @return the string
     * @author : Yvon / 2020-08-13
     */
    String message() default "身份证号码不符合规范!";

    /**
     * Groups class [ ].
     *
     * @return the class [ ]
     * @author : Yvon / 2020-08-13
     */
    Class<?>[] groups() default { };

    /**
     * Payload class [ ].
     *
     * @return the class [ ]
     * @author : Yvon / 2020-08-13
     */
    Class<? extends Payload>[] payload() default { };

    /**
     * @author : Yvon
     * @version : 1.0
     */
    @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
    @Retention(RUNTIME)
    @Documented
    @interface List {
        /**
         * Value id card [ ].
         *
         * @return the id card [ ]
         * @author : Yvon / 2020-08-13
         */
        IdCard[] value();
    }
}
